package thread;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏西西
 * Date: 2023-08-31
 * Time: 8:43
 */
class  MyCounter{
    volatile public int  flag = 0;
        }
public class ThreadDemo15 {
    public static void main(String[] args) {
        MyCounter myCounter = new MyCounter();
        Thread t1 = new Thread(() ->{
            while (myCounter.flag == 0){

            }
            System.out.println("t1循环结束");
        });

        Thread t2 = new Thread(() ->{
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入一个整数");
            myCounter.flag = scanner.nextInt();
        });
        t1.start();
        t2.start();
    }
}
